Abstract In this contribution, an iterative algorithm of total least squares is organized for fitting spatial lines. We projected spatial straight lines to coordinate planes perpendicularly, and then total least squares (TLS) and least squares (LS) are employed to fit the plane's lines. A simulated experiment with three scenarios is designed to compare the estimated parameters and the variance of unit weight from TLS and LS, respectively. In scenario one, the error of all points is normally distributed with zero mean and identical standard deviation. In the second scenario, the error of each point is normally distributed with zero mean and different standard deviation. In scenario three, the error of point coordinate components is normally distributed with zero mean and different standard deviation. In addition, in a second experiment, a set of laser scanned data points are fitted by TLS and LS, respectively.